#include <bits/stdc++.h>

using namespace std;

const int MAXN = 3e5+10;

typedef struct {int v,nxt;}edge;

int f[MAXN],siz[MAXN],ans,h[MAXN],cnt,n,m;
edge e[MAXN<<1];

void link(int x,int y){e[++cnt] = edge{y,h[x]};h[x] = cnt;}

void dfs(int x,int p){
	f[x] = 1;
	int mx = 0,mmx = 0;
	for(int i = h[x];i;i = e[i].nxt){
		int y = e[i].v; if(y == p) continue;
		dfs(y,x);
		f[x]++;
		if(f[y] > mx) mmx = mx,mx = f[y];
		else if(f[y] > mmx) mmx = f[y];
	}
	f[x] += max(mx - 1,0);
	ans = max(ans,f[x] + max(mmx - 1,0) + (p != 0));
}

int main (){
	scanf("%d %d",&n,&m);
	while(m--){
		int x,y;scanf("%d %d",&x,&y);
		link(x,y);link(y,x);
	}
	dfs(1,0);
	printf("%d\n",ans);
	return 0;
}
